<template>
    <div class="wy-main business-car-manage">
     <div class="my-main-cont" style="margin-left: 30px">
         <a-input v-model="licence" placeholder="请输入车牌号" style="width: 200px"/>
         <a-button type="primary" style="margin-left: 10px;" @click="getcarSource">查询</a-button>
		     <a-button style="margin-left: 15px;" @click="reset">重置</a-button>
         <a-button class="title-button" type="primary">批量审核</a-button>
         <a-table :columns="columns" :rowKey="record => record.vehicleinfoId" :dataSource="cardata" :rowSelection="rowSelection" :pagination="pagination" :loading="loading" style="margin-top: 20px" >
					 	<span slot="action" slot-scope="text, record">
		         <a href="javascript:;" @click="edit(record)">审核</a>
		        </span>
         </a-table>
          <div style="margin-top: -50px">
            <a-button @click="delAll">删除所选</a-button>
          </div>
     </div>
		 <a-modal :title="type == 'edit' ? '车源审核' : '查看车源信息'" :visible="visible" @cancel="handleCancel" width="900px" :maskClosable='false' :footer="null" >
			  <publish-add v-if="visible" :datail='datail' @close="close" :type='type'></publish-add>
		 </a-modal>
    </div>
</template>
<script>
import publishAdd from './Publish'
const columns = [{
		title: '司机',
		dataIndex: 'driverName',
		key: 'driverName',
	},{
		title: '驾驶员联系电话',
		dataIndex: 'driverMobile',
		key: 'driverMobile',
	},{
		title: '车牌号',
		dataIndex: 'licence',
		key: 'licence',
		scopedSlots: {
			customRender: 'licence'
		},
	},{
		title: '车辆常驻地',
		dataIndex: 'residence',
		key: 'residence',
	},{
		title: '提交日期',
		dataIndex: 'releaseDate',
		key: 'releaseDate',
	},{
		title: '备注',
		dataIndex: 'remarks',
		key: 'remarks',
	},
	{
		title: '操作',
		key: '0',
		scopedSlots: {
			customRender: 'action'
		},
	}];

const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  },
  onSelect: (record, selected, selectedRows) => {
    console.log(record, selected, selectedRows);
  },
  onSelectAll: (selected, selectedRows, changeRows) => {
    console.log(selected, selectedRows, changeRows);
  },
};
export default {
    
    data() {
        return {
				type: '',
				visible: false,
         columns,
				 cardata:[],
				 datail: {},
         loading: false,
         licence: '',
         rowSelection,
         	pagination: {
          ageSizeOptions: ['10', '20', '30', '40', '100'],
				  defaultCurrent: 1, //默认的当前页数
				  defaultPageSize: 10, //默认的每页条数
				  showSizeChanger: true,
          total:0,
				  showTotal: (total, range) => `共 ${total} 条记录`
				},
        }
    }, 
    created() {
      this.getcarSource()
		},
		components: {
			publishAdd
		},
    methods: {
			//修改完毕刷新数据
				close(){
				this.visible = false
				this.getcarSource()
			},
			//审核货物信息
			edit(data){
				this.type = 'edit'
				this.visible = true
		    this.datail = data
			},
				// 关闭弹窗
			handleCancel(){
				this.visible = false
			},

			
			//删除
			delAll() {
				this.$confirm({
					title: '确定删除所选中的记录？',
					content: '当您点击确定按钮后，这些记录将会被彻底删除',
					centered: true
				})

			},
      //重置
      reset () {
				this.pagination.defaultCurrent = 1;
				this.licence = '';
				this.getcarSource();
			},
			
			//获取车源信息
				getcarSource(params={}){
				this.loading = true
				// params.licence = this.licence
				params.pageSize = this.pagination.defaultPageSize
				params.pageNum = this.pagination.defaultCurrent
				// params.licence= this.licence
				this.$get('/info/infoVehicleinfo/open/getVehicleinfoList', params).then((r) => {
					this.loading = false
					console.log(r)
					this.cardata = r.data.data.rows
				})
			},
    }
}
</script>
<style lang="less">
.title-button{
    float:right;

}
</style>
